package com.jctrip.hotel.route.config;

import com.jctrip.hotel.route.interceptor.RouteOpenApiInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注意加入顺序
        registry.addInterceptor(routeOpenApiInterceptor())
                .addPathPatterns("/route/**");
    }

    @Bean
    public RouteOpenApiInterceptor routeOpenApiInterceptor() {
        return new RouteOpenApiInterceptor();
    }
}
